﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DCT.Huiteng.Utility
{
    public static class DateTimeUtility
    {
        private static DateTime DateTime19700101 = DateTime.Parse("1970-01-01");

        /// <summary>
        /// 参数时间距离1970-01-01的毫秒数
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static long DateTimeFrom19700101(DateTime time) {
            TimeSpan ts = time - DateTime19700101;
            return (long)ts.TotalMilliseconds;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="millisecond"></param>
        /// <returns></returns>
        public static DateTime MillisecondsTo19700101(long millisecond) {
            return DateTime19700101.AddMilliseconds(millisecond);
        }
    }
}
